/*
 * Copyright 2012 Marsrutai.lt
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package lt.marsrutai.mobile.android.model;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

public class RouteSearchResult implements Parcelable {

    public static Creator<RouteSearchResult> CREATOR = new Creator<RouteSearchResult>() {
        
        @Override
        public RouteSearchResult[] newArray(int size) {
            return new RouteSearchResult[size];
        }
        
        @Override
        public RouteSearchResult createFromParcel(Parcel source) {
            return new RouteSearchResult(source);
        }
    };
    
    private List<Route> routes = new ArrayList<Route>();
    private RouteSearchStatus startStatus;
    private RouteSearchStatus endStatus;
    private List<String> startChoices = new ArrayList<String>();
    private List<String> endChoices = new ArrayList<String>();

    public RouteSearchResult() {
    }
    
    public RouteSearchResult(Parcel in) {
        in.readList(routes, Route.class.getClassLoader());
        if (in.readInt() == 1) {
            startStatus = RouteSearchStatus.valueOf(in.readString());
        }
        if (in.readInt() == 1) {
            endStatus = RouteSearchStatus.valueOf(in.readString());
        }
        in.readStringList(startChoices);
        in.readStringList(endChoices);
    }
    
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeList(routes);
        
        if (startStatus == null) {
            dest.writeInt(0);
        }
        else {
            dest.writeInt(1);
            dest.writeString(startStatus.name());
        }
        
        if (endStatus == null) {
            dest.writeInt(0);
        }
        else {
            dest.writeInt(1);
            dest.writeString(endStatus.name());
        }
        dest.writeStringList(startChoices);
        dest.writeStringList(endChoices);
    }
    
    @Override
    public int describeContents() {
        return 0;
    }
    
    public List<Route> getRoutes() {
        return routes;
    }

    public void setRoutes(List<Route> routes) {
        this.routes = routes;
    }

    public RouteSearchStatus getStartStatus() {
        return startStatus;
    }

    public void setStartStatus(RouteSearchStatus startStatus) {
        this.startStatus = startStatus;
    }

    public RouteSearchStatus getEndStatus() {
        return endStatus;
    }

    public void setEndStatus(RouteSearchStatus endStatus) {
        this.endStatus = endStatus;
    }

    public List<String> getStartChoices() {
        return startChoices;
    }

    public void setStartChoices(List<String> startChoices) {
        this.startChoices = startChoices;
    }

    public List<String> getEndChoices() {
        return endChoices;
    }

    public void setEndChoices(List<String> endChoices) {
        this.endChoices = endChoices;
    }
}
